<?php

namespace app\admin\model\pricereviewmanagent;

use think\Model;
use think\Db;
use traits\model\SoftDelete;

class PricingReviewItems extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'pricing_review_items';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [

    ];

    public function base($query)
    {
        $query->alias('pricing_review_items')->where('pricing_review_items.caijiakuid',CAIJIAKU_ID)->useSoftDelete('pricing_review_items.'.$this->deleteTime);
    }
    
    public static function init()
    {
        self::beforeInsert(function ($row) {
            $row->caijiakuid = CAIJIAKU_ID;
        });
    }

    public function pricingreview()
    {
        return $this->belongsTo('PricingReview', 'project_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    
    public function admin()
    {
        return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

}
